home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 26
/
AMIGAplus Sonderheft 26 (2000)(Falke)(DE)(Track 1 of 2)[!].iso
/
Tools
/
GFX-Viewer
/
SViewII
/
SvII-GL
/
sviewmesa.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-03-29
|
3KB
|
149 lines
/*
** $VER: sviewmesa.c 1.00 (24.11.98)
**
** SuperView output driver for AMesaRTL Shared Library
**
** (C) Copyright 1998 Andreas R. Kleinert
** All Rights Reserved.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/utility.h>
#include "gl/outputhandler.h"
AmigaMesaRTLContext ctx;
struct Library *mesadriverBase;
__asm __saveds int InitOutputHandlerA(register __a0 AmigaMesaRTLContext mesacontext, register __a1 struct TagItem *tags)
{
long mode;
ctx = mesacontext;
if (!(mesadriverBase = (struct Library *) GetTagData(OH_DriverBase,NULL,tags))) return(0);
if(!stricmp(GetTagData(OH_OutputType,"",tags),"window"))
if (!GetTagData(OH_Output,0,tags)) return(0);
AmigaMesaRTLGetContextAttr(AMRTL_Mode,mesacontext,&mode);
if(mode == AMRTL_RGBAMode)
{
/* init */
return(1);
}
DeleteOutputHandler();
return(0);
}
__asm __saveds void DeleteOutputHandler(void)
{
}
__asm __saveds int ResizeOutputHandler(void)
{
return(1);
}
ULONG width = 640;
ULONG height = 480;
__asm __saveds int ProcessOutput(void)
{
UBYTE *src;
ULONG i, j;
BPTR handle;
char name[64];
if(!FindPort("SViewII.rx")) Execute("SViewII -OPEN_GUI", NULL, Output());
AmigaMesaRTLGetContextAttr(AMRTL_Buffer,ctx, &src);
AmigaMesaRTLGetContextAttr(AMRTL_BufferWidth,ctx, &width);
sprintf(name, "VMEM:sviewmesa_%lx", &handle);
handle = Open(name, MODE_NEWFILE);
if(handle)
{
UBYTE header[64];
UBYTE name2[64];
sprintf(&header[0], "P6\n%ld %ld\n255\n", width, height);
FWrite(handle, &header[0], strlen(header), 1);
for(i=0; i<height; i++)
{
for(j=0; j<width; j++)
{
FWrite(handle, src, 3, 1);
src += 4;
}
}
Close(handle);
sprintf(header, "/* */\naddress 'SViewII.rx'\n'LOAD=%s'\n", name);
sprintf(name2, "VMEM:sviewmesa_%lx", &handle + 1);
handle = Open(name2, MODE_NEWFILE);
if(handle)
{
Write(handle, header, strlen(header));
Close(handle);
}
sprintf(header, "rx %s", name2);
if(!FindPort("SViewII.rx")) Delay(100);
if(!FindPort("SViewII.rx")) Delay(100);
if(!FindPort("SViewII.rx")) Delay(100);
if(!FindPort("SViewII.rx")) Delay(100);
if(!FindPort("SViewII.rx")) Delay(100);
if(!FindPort("SViewII.rx")) Delay(100);
if(!FindPort("SViewII.rx")) Delay(100);
Execute(header, NULL, Output());
DeleteFile(name);
DeleteFile(name2);
}else return(0);
return(1);
}
__asm __saveds void SetIndexRGBTable(register __d0 int index, register __a0 ULONG *rgbtable, register __d1 int numcolours)
{
}
__asm __saveds ULONG SetOutputHandlerAttrsA(register __a0 struct TagItem *tags)
{
return(0);
}
__asm __saveds ULONG GetOutputHandlerAttr(register __d0 ULONG attr, register __a0 ULONG *data)
{
switch(attr)
{
case OH_Width: *data = width; break;
case OH_Height: *data = height; break;
default: return(0);
}
return(1);
}
void __stdargs _XCEXIT(long dummy)
{
}